It has been shown how matrix grammars can be extended with tables and how the generative power is enlarged. In this section we will remove the restriction that the vertical derivation of matrix grammars is only directed downwards. In this way, pictures other than rectangular ones can be generated. The definition is from \cite{krithivasan1977variations}.  

\begin{definition}
	A PSMG (CSMG, CFMG, RLMG) $G = (G_H, G_V)$ is called \emph{extended phrase-structure matrix grammar} (Ex-PSMG) (\emph{extended context-sensitive matrix grammar} (Ex-CSMG), \emph{extended context-free matrix grammar} (Ex-CFMG), \emph{extended regular matrix grammar} (Ex-RMG) ), when each intermediate symbol $S_i \in I$ from $G_H$ is attached to another symbol d or u (down or up) to determine the direction of vertical derivations.
\end{definition}

The derivation starts as usual. From the start symbol $S$, a string $S_{i_1} \dots S_{i_n} \in I^*$ is generated by the horizontal grammar. Assuming that the first symbol in the string is $S_k$ ($1 \leq k \leq |I|$) and appears 3 times, we have $S_{i_1} \dots S_{i_n} = S_k \dots S_k \dots S_k \dots $. The vertical derivation starts with any column $S_k$ is placed at. If d is attached to the intermediate $S_k$ the derivation starts downwards, if u is attached to $S_k$ the derivation starts upwards. The derivation is continued only in these columns, until a terminal rule is applied simultaneously. If a terminal rule has been applied, the derivation proceeds with the next intermediate in the string which has not yet been processed.

If an upwards derivation is applied, we will write this as $\Uparrow$. As usual, $\overset{*}{\Uparrow}$ is the reflexive, transitive closure of $\Uparrow$. For reflexive, transitive closure of $\Uparrow \cup \Downarrow$ is written as $\overset{*}{\Downarrow}\overset{*}{\Uparrow}$. 

To make the process of derivation clear to the reader, we will continue with an example. 

\begin{example}
	Let $L(G) = (L)::(R_1, R_2)$ be an extended matrix grammar with the attached symbols (d, u) where
	\begin{compactitem}
		\item $L = \{S_1^nS_2^n \mid n \geq 1\}$
		\item $R_1 = \{x^n \mid n \geq 1\}$ 
		\item $R_2 = \{.^n \mid n \geq 1\}$
	\end{compactitem}
	
	The horizontal language can be generated by a context-free grammar. Thus, $L(G)$ is an Ex-CFMG. 
	
	$L(G)$ generates pictures, beginning with downward rectangle of x's and ends with upward rectangle of .'s. 
\end{example}

To point out the principle of derivation, we will show an example derivation generating a picture with a rectangle of size (4, 3) of x's and a rectangle of size (2, 3) of .'s. 

\begin{center}
	\begin{longtable}{cc}
		$S \overset{*}{\Rightarrow} $  & \boxed{
			\begin{aligned}
				\begin{matrix}
					S_1 & S_1 & S_1 & S_2 & S_2 & S_2
				\end{matrix}
			\end{aligned}
		}\\ %new line of longtable
		& $\Downarrow$ \\ %new line of longtable
		& \boxed{
			\begin{aligned}
				\begin{matrix}
					x & x & x & S_2 & S_2 & S_2 \\[-0.5ex]
					S_1 & S_1 & S_1
				\end{matrix}
			\end{aligned}
		}\\ %new line of longtable
		& $\overset{*}{\Downarrow}$ \\ %new line of longtable
		& \boxed{
			\begin{aligned}
				\begin{matrix}
					x & x & x & S_2 & S_2 & S_2 \\[-0.5ex]
					x & x & x \\[-0.5ex]
					x & x & x \\[-0.5ex]
					S_1 & S_1 & S_1
				\end{matrix}
			\end{aligned}
		}\\ %new line of longtable
		& $\Downarrow$ \\ %new line of longtable
		& \boxed{
			\begin{aligned}
				\begin{matrix}
					x & x & x & S_2 & S_2 & S_2 \\[-0.5ex]
					x & x & x \\[-0.5ex]
					x & x & x \\[-0.5ex]
					x & x & x
				\end{matrix}
			\end{aligned}
		}\\ %new line of longtable
		& $\Uparrow$  \\ %new line of longtable
		& \boxed{
			\begin{aligned}
				\begin{matrix}
					&  &  & S_2 & S_2 & S_2 \\[-0.5ex]
					x & x & x & . & . & . \\[-0.5ex]
					x & x & x \\[-0.5ex]
					x & x & x \\[-0.5ex]
					x & x & x
				\end{matrix}
			\end{aligned}
		} \\ %new line of longtable
		& $\Uparrow$  \\ %new line of longtable
		& \boxed{
			\begin{aligned}
				\begin{matrix}
					&  &  & . & . & . \\[-0.5ex]
					x & x & x & . & . & . \\[-0.5ex]
					x & x & x \\[-0.5ex]
					x & x & x \\[-0.5ex]
					x & x & x
				\end{matrix}
			\end{aligned}
		}
	\end{longtable}
\end{center}

We can now define the language generated by an Ex-PSMG. For Ex-CSMG, Ex-CFMG and Ex-RMG the definition is similar. 

\begin{definition}
	The language generated by an Ex-PSMG G is 
	
	\[L(G) = \{p \mid S \overset{*}{\Rightarrow} S_{i_1} \dots S_{i_{l_2(p)}} \overset{*}{\Downarrow}\overset{*}{\Uparrow} p \}\]
	
	and is called \emph{extended phrase-structure matrix language} (Ex-PSML). 
\end{definition}

The family of all languages of Ex-PSML, Ex-CSML, Ex-CFML and Ex-RML are denoted as $\familyOf{Ex-PSML}$, $\familyOf{Ex-CSML}$, $\familyOf{Ex-CFML}$ and $\familyOf{Ex-RML}$ respectively. 

Due to the Chomsky hierarchy, we also have a hierarchy for extended matrix languages which is $\familyOf{Ex-RML} \subset \familyOf{Ex-CFML} \subset \familyOf{Ex-CSML} \subset \familyOf{Ex-PSML}$. 

To extend this model with control, it is possible to use control words or control sets while deriving pictures of the language. These control words are words in $I^*$. Each character in a control word $w = w_1 \dots w_k$ forces the derivation to make one derivation step in the columns with intermediate $w_1$. It is continued with $w_2$ and so on. Thus, we can handle the vertical proportions of different parts of the pictures. 

As a second enhancement, it is possible to start the upwards derivation one line above. Hence, there is space for each column to derive upwards and downwards at the same time. This approach allows a generalization of the attached symbols. Instead of symbols, numbers representing the angle of derivation in degrees can be used. Upward and downward are represented by 0 and 180 degrees, respectively. Therefore, it is possible to create 3 dimensional objects. Details on both approaches can be found in \cite{krithivasan1977variations}. 

More about extensions of the matrix models can be found in \cite{subramanian1985extension} and \cite{siromoney1986advances}. 

\label{extensions_matrix_grammars}